-
-
Notifications
You must be signed in to change notification settings - Fork 104
Automated Resyntax fixes #1410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automated Resyntax fixes #1410
Conversation
This is an automated change generated by Resyntax. #### Pass 1 Applied 1 fix to [`typed-racket-lib/typed-racket/types/tc-error.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/tc-error.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 10 fixes to [`typed-racket-lib/typed-racket/types/printer.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/printer.rkt) * Line 135, `quasiquote-to-list`: This quasiquotation is equialent to a simple `list` call. * Line 152, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 163, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 320, `define-values-values-to-define`: This use of `define-values` is unnecessary. * Line 327, `for/fold-result-keyword`: Only one of the `for/fold` expression's result values is used. Use the `#:result` keyword to return just that result. * Line 367, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 464, `apply-append-for-loop-to-for-loop`: Instead of using `(apply append ...)` to flatten a list of lists, consider using `for*/list` to flatten the list. * Line 480, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 515, `quasiquote-to-list`: This quasiquotation is equialent to a simple `list` call. * Line 519, `quasiquote-to-list`: This quasiquotation is equialent to a simple `list` call. Applied 2 fixes to [`typed-racket-lib/typed-racket/types/tc-result.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/tc-result.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 158, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. Applied 1 fix to [`typed-racket-lib/typed/private/no-check-helper.rkt`](../blob/HEAD/typed-racket-lib/typed/private/no-check-helper.rkt) * Line 5, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 6 fixes to [`typed-racket-lib/typed-racket/types/base-abbrev.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/base-abbrev.rkt) * Line 105, `define-syntax-syntax-rules-to-define-syntax-rule`: This `define-syntax` macro can be replaced with a simpler, equivalent `define-syntax-rule` macro. * Line 109, `define-syntax-syntax-rules-to-define-syntax-rule`: This `define-syntax` macro can be replaced with a simpler, equivalent `define-syntax-rule` macro. * Line 496, `define-syntax-syntax-rules-to-define-syntax-rule`: This `define-syntax` macro can be replaced with a simpler, equivalent `define-syntax-rule` macro. * Line 502, `define-syntax-syntax-rules-to-define-syntax-rule`: This `define-syntax` macro can be replaced with a simpler, equivalent `define-syntax-rule` macro. * Line 509, `define-syntax-syntax-rules-to-define-syntax-rule`: This `define-syntax` macro can be replaced with a simpler, equivalent `define-syntax-rule` macro. * Line 516, `define-syntax-syntax-rules-to-define-syntax-rule`: This `define-syntax` macro can be replaced with a simpler, equivalent `define-syntax-rule` macro. Applied 3 fixes to [`typed-racket-test/external/tr-random-testing.rkt`](../blob/HEAD/typed-racket-test/external/tr-random-testing.rkt) * Line 5, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 10, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 337, `if-begin-to-cond`: Using `cond` instead of `if` here makes `begin` unnecessary Applied 3 fixes to [`typed-racket-lib/typed-racket/types/signatures.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/signatures.rkt) * Line 6, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 52, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 59, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. Applied 1 fix to [`typed-racket-lib/typed-racket/types/struct-table.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/struct-table.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 3 fixes to [`typed-racket-lib/typed-racket/types/utils.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/utils.rkt) * Line 19, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. * Line 60, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 79, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. Applied 4 fixes to [`typed-racket-lib/typed-racket/types/prop-ops.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/prop-ops.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 56, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 111, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 382, `sort-with-keyed-comparator-to-sort-by-key`: This `sort` expression can be replaced with a simpler, equivalent expression. Applied 1 fix to [`typed-racket-lib/typed-racket/types/union.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/union.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 2 fixes to [`typed-racket-lib/typed-racket/types/generalize.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/generalize.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 48, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. Applied 1 fix to [`typed-racket-test/external/historical-counterexamples.rkt`](../blob/HEAD/typed-racket-test/external/historical-counterexamples.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 1 fix to [`typed-racket-lib/typed-racket/types/substitute.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/substitute.rkt) * Line 78, `if-let-to-cond`: `cond` with internal definitions is preferred over `if` with `let`, to reduce nesting Applied 1 fix to [`typed-racket-lib/typed-racket/types/overlap.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/overlap.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 3 fixes to [`typed-racket-lib/typed-racket/types/subtype.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/subtype.rkt) * Line 536, `apply-flattening`: The `apply` function accepts single arguments in addition to a trailing list argument. * Line 661, `if-else-false-to-and`: This `if` expression can be refactored to an equivalent expression using `and`. * Line 793, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. Applied 2 fixes to [`typed-racket-lib/typed/private/rewriter.rkt`](../blob/HEAD/typed-racket-lib/typed/private/rewriter.rkt) * Line 2, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 10, `syntax-disarm-migration`: The `syntax-disarm` function is a legacy function that does nothing. Applied 2 fixes to [`typed-racket-lib/typed-racket/types/match-expanders.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/match-expanders.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 78, `define-simple-macro-to-define-syntax-parse-rule`: The `define-simple-macro` form has been renamed to `define-syntax-parse-rule`. Applied 3 fixes to [`typed-racket-lib/typed-racket/types/resolve.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/resolve.rkt) * Line 52, `if-else-false-to-and`: This `if` expression can be refactored to an equivalent expression using `and`. * Line 65, `inverted-when`: This negated `when` expression can be replaced by an `unless` expression. * Line 101, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. ## Summary Fixed 50 issues in 19 files. * Fixed 14 occurrences of `tidy-require` * Fixed 7 occurrences of `single-clause-match-to-match-define` * Fixed 7 occurrences of `let-to-define` * Fixed 6 occurrences of `define-syntax-syntax-rules-to-define-syntax-rule` * Fixed 3 occurrences of `quasiquote-to-list` * Fixed 2 occurrences of `if-else-false-to-and` * Fixed 1 occurrence of `define-values-values-to-define` * Fixed 1 occurrence of `for/fold-result-keyword` * Fixed 1 occurrence of `apply-append-for-loop-to-for-loop` * Fixed 1 occurrence of `if-let-to-cond` * Fixed 1 occurrence of `apply-flattening` * Fixed 1 occurrence of `syntax-disarm-migration` * Fixed 1 occurrence of `define-simple-macro-to-define-syntax-parse-rule` * Fixed 1 occurrence of `inverted-when` * Fixed 1 occurrence of `if-begin-to-cond` * Fixed 1 occurrence of `define-lambda-to-define` * Fixed 1 occurrence of `sort-with-keyed-comparator-to-sort-by-key`
|
Bitten by jackfirth/resyntax#383 yet again. |
| ;; case-lambda->sexp : Type -> S-expression | ||
| ;; Convert a case-> type to an s-expression | ||
| (define (case-lambda->sexp type) | ||
| (match type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two matches could be combined which would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I agree, particularly since the third branch of the second match wants to refer to the arrows variable anyway. This is how I'd write it:
(match-define (Fun: arrows) type)
(match arrows
[(list) '(case->)]
[(list a) (arr->sexp a)]
[(list a b ...)
(define cover (cover-case-lambda arrows))
(if (> (length cover) 1)
`(case-> ,@cover)
(car cover))])There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I think I prefer:
(match type
[(Fun: (list)) '(case->)]
[(Fun: (list a)) (arr->sexp a)]
[(Fun: arrows)
(define cover (cover-case-lambda arrows))
(if (> (length cover) 1)
`(case-> ,@cover)
(car cover))])
but that might be hard to generate automatically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks quite reasonable. However, this all seems way too subjective for Resyntax to tackle.
This is an automated change generated by Resyntax.
Pass 1
Applied 1 fix to
typed-racket-lib/typed-racket/types/tc-error.rkttidy-require: Keep imports inrequiresorted and grouped by phase, with collections before files.Applied 10 fixes to
typed-racket-lib/typed-racket/types/printer.rktquasiquote-to-list: This quasiquotation is equialent to a simplelistcall.single-clause-match-to-match-define: Thismatchexpression can be simplified usingmatch-define.single-clause-match-to-match-define: Thismatchexpression can be simplified usingmatch-define.define-values-values-to-define: This use ofdefine-valuesis unnecessary.for/fold-result-keyword: Only one of thefor/foldexpression's result values is used. Use the#:resultkeyword to return just that result.single-clause-match-to-match-define: Thismatchexpression can be simplified usingmatch-define.apply-append-for-loop-to-for-loop: Instead of using(apply append ...)to flatten a list of lists, consider usingfor*/listto flatten the list.single-clause-match-to-match-define: Thismatchexpression can be simplified usingmatch-define.quasiquote-to-list: This quasiquotation is equialent to a simplelistcall.quasiquote-to-list: This quasiquotation is equialent to a simplelistcall.Applied 2 fixes to
typed-racket-lib/typed-racket/types/tc-result.rkttidy-require: Keep imports inrequiresorted and grouped by phase, with collections before files.single-clause-match-to-match-define: Thismatchexpression can be simplified usingmatch-define.Applied 1 fix to
typed-racket-lib/typed/private/no-check-helper.rkttidy-require: Keep imports inrequiresorted and grouped by phase, with collections before files.Applied 6 fixes to
typed-racket-lib/typed-racket/types/base-abbrev.rktdefine-syntax-syntax-rules-to-define-syntax-rule: Thisdefine-syntaxmacro can be replaced with a simpler, equivalentdefine-syntax-rulemacro.define-syntax-syntax-rules-to-define-syntax-rule: Thisdefine-syntaxmacro can be replaced with a simpler, equivalentdefine-syntax-rulemacro.define-syntax-syntax-rules-to-define-syntax-rule: Thisdefine-syntaxmacro can be replaced with a simpler, equivalentdefine-syntax-rulemacro.define-syntax-syntax-rules-to-define-syntax-rule: Thisdefine-syntaxmacro can be replaced with a simpler, equivalentdefine-syntax-rulemacro.define-syntax-syntax-rules-to-define-syntax-rule: Thisdefine-syntaxmacro can be replaced with a simpler, equivalentdefine-syntax-rulemacro.define-syntax-syntax-rules-to-define-syntax-rule: Thisdefine-syntaxmacro can be replaced with a simpler, equivalentdefine-syntax-rulemacro.Applied 3 fixes to
typed-racket-test/external/tr-random-testing.rkttidy-require: Keep imports inrequiresorted and grouped by phase, with collections before files.tidy-require: Keep imports inrequiresorted and grouped by phase, with collections before files.if-begin-to-cond: Usingcondinstead ofifhere makesbeginunnecessaryApplied 3 fixes to
typed-racket-lib/typed-racket/types/signatures.rkttidy-require: Keep imports inrequiresorted and grouped by phase, with collections before files.let-to-define: Internal definitions are recommended instead ofletexpressions, to reduce nesting.let-to-define: Internal definitions are recommended instead ofletexpressions, to reduce nesting.Applied 1 fix to
typed-racket-lib/typed-racket/types/struct-table.rkttidy-require: Keep imports inrequiresorted and grouped by phase, with collections before files.Applied 3 fixes to
typed-racket-lib/typed-racket/types/utils.rktdefine-lambda-to-define: Thedefineform supports a shorthand for defining functions.let-to-define: Internal definitions are recommended instead ofletexpressions, to reduce nesting.let-to-define: Internal definitions are recommended instead ofletexpressions, to reduce nesting.Applied 4 fixes to
typed-racket-lib/typed-racket/types/prop-ops.rkttidy-require: Keep imports inrequiresorted and grouped by phase, with collections before files.single-clause-match-to-match-define: Thismatchexpression can be simplified usingmatch-define.let-to-define: Internal definitions are recommended instead ofletexpressions, to reduce nesting.sort-with-keyed-comparator-to-sort-by-key: Thissortexpression can be replaced with a simpler, equivalent expression.Applied 1 fix to
typed-racket-lib/typed-racket/types/union.rkttidy-require: Keep imports inrequiresorted and grouped by phase, with collections before files.Applied 2 fixes to
typed-racket-lib/typed-racket/types/generalize.rkttidy-require: Keep imports inrequiresorted and grouped by phase, with collections before files.let-to-define: Internal definitions are recommended instead ofletexpressions, to reduce nesting.Applied 1 fix to
typed-racket-test/external/historical-counterexamples.rkttidy-require: Keep imports inrequiresorted and grouped by phase, with collections before files.Applied 1 fix to
typed-racket-lib/typed-racket/types/substitute.rktif-let-to-cond:condwith internal definitions is preferred overifwithlet, to reduce nestingApplied 1 fix to
typed-racket-lib/typed-racket/types/overlap.rkttidy-require: Keep imports inrequiresorted and grouped by phase, with collections before files.Applied 3 fixes to
typed-racket-lib/typed-racket/types/subtype.rktapply-flattening: Theapplyfunction accepts single arguments in addition to a trailing list argument.if-else-false-to-and: Thisifexpression can be refactored to an equivalent expression usingand.single-clause-match-to-match-define: Thismatchexpression can be simplified usingmatch-define.Applied 2 fixes to
typed-racket-lib/typed/private/rewriter.rkttidy-require: Keep imports inrequiresorted and grouped by phase, with collections before files.syntax-disarm-migration: Thesyntax-disarmfunction is a legacy function that does nothing.Applied 2 fixes to
typed-racket-lib/typed-racket/types/match-expanders.rkttidy-require: Keep imports inrequiresorted and grouped by phase, with collections before files.define-simple-macro-to-define-syntax-parse-rule: Thedefine-simple-macroform has been renamed todefine-syntax-parse-rule.Applied 3 fixes to
typed-racket-lib/typed-racket/types/resolve.rktif-else-false-to-and: Thisifexpression can be refactored to an equivalent expression usingand.inverted-when: This negatedwhenexpression can be replaced by anunlessexpression.let-to-define: Internal definitions are recommended instead ofletexpressions, to reduce nesting.Summary
Fixed 50 issues in 19 files.
tidy-requiresingle-clause-match-to-match-definelet-to-definedefine-syntax-syntax-rules-to-define-syntax-rulequasiquote-to-listif-else-false-to-anddefine-values-values-to-definefor/fold-result-keywordapply-append-for-loop-to-for-loopif-let-to-condapply-flatteningsyntax-disarm-migrationdefine-simple-macro-to-define-syntax-parse-ruleinverted-whenif-begin-to-conddefine-lambda-to-definesort-with-keyed-comparator-to-sort-by-key